#include <stdio.h>
#include "Includes/Driver.h"
#include "Includes/Rendering.h"
#include "Includes/Messaging.h"
#include "Includes/Window.h"
#include <unistd.h>

/// <summary>
/// Global Message Map
/// </summary>
const MSGInvoke MessageMap[0x400] =
{
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	NULL, // Reserved
	/*CreateWindowByMessage, // 20
	ShowWindow, // 21
	HideWindow, // 22
	MoveWindow, // 23
	DestroyWindow, // 24
*/
	NULL
};

/// <summary>
/// Message Map
/// </summary>
int MSGDispatch(MessagePtr msg)
{
	if (msg == NULL)
		return -1;

	if (msg->mid >= 0x400)
		return -2;

	if (MessageMap[msg->mid] == NULL)
		return -3;

	if (MessageMap[msg->mid](msg) < 0)
		return -4;

	return 0;
}
